package com.yinxin.reflection.InvocationProxy.cjlib;


import net.sf.cglib.proxy.Enhancer;
import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;

/**
 * @author yinxin
 * @version 1.0
 * @Description:
 * @date 2022/8/1816:48
 */
public class CGLIBProxy implements MethodInterceptor {
    private Object object;

    public CGLIBProxy(Object object) {
        this.object = object;
    }

    // 创建代理对象
    public Object createProxy() {
        return Enhancer.create(object.getClass(), this);
    }

    @Override
    public Object intercept(Object o, Method method, Object[] objects, MethodProxy methodProxy) throws Throwable {
        System.out.println("*********当前时间->xxxxx");
        methodProxy.invoke(object, objects);
        return null;
    }
}
